/**************************************************************************
 *         Copyright(c) 2007 by Sunplus mMedia  Technology Co., Ltd.       *
 *                                                                         *
 *  This software is copyrighted by and is the property of Sunplus mMedia  *
 *  Technology Co., Ltd. All rights are reserved by Sunplus mMedia Techno- *
 *  logy Co., Ltd. This software may only be used in accordance with the   *
 *  corresponding license agreement. Any unauthorized use, duplication,    *
 *  distribution, or disclosure of this software is expressly forbidden.   *
 *                                                                         *
 *  This Copyright notice "M U S T" not be removed or modified without     *
 *  prior written consent of Sunplus mMedia Technology  Co., Ltd.          *
 *                                                                         *
 *  Sunplus mMedia Technology Co., Ltd. reserves the right to modify this  *
 *  software without notice.                                               *
 *                                                                         *
 *  Sunplus mMedia Technology Co., Ltd.                                    *
 *  19-1, Innovation First Road, Science-Based Industrial Park,            *
 *  Hsin-Chu, Taiwan, R.O.C.                                               *
 *                                                                         *
 **************************************************************************/
#ifndef __SIDCMAIN_H__
#define __SIDCMAIN_H__

#define SIDC_PARA_FILE_INFO_SIZE (sizeof(SIDC_PARA_FILE_INFO))
typedef struct SIDC_PARA_FILE_INFO_
{
	UINT32 handle;
	UINT8 filePath[33];
	UINT8* fileName;
	UINT16 fileType;
	UINT32 fileSize;
	UINT16 width;
	UINT16 height;
	UINT32 thembAddr;
	UINT32 thembSize;
	UINT16 thembWidth;
	UINT16 thembHeight;
	UINT16 other;
}SIDC_PARA_FILE_INFO,*PSIDC_PARA_FILE_INFO;

//--handle:
//--path||file
//--dev|dir||type|idx
#define sidc_writeHandlePath(handle,dev,dir) ((UINT16*)&handle)[0]=((UINT16)dev<<12)|((UINT16)dir)
#define sidc_writeHandleFile(handle,type,idx) ((UINT16*)&handle)[1]=((UINT16)type<<14)|((UINT16)idx)

#define sidc_readHandleDev(handle,dev) dev=(*(UINT8*)&handle)>>4
#define sidc_readHandleDir(handle,dir) dir=(*(UINT16*)&handle)&0x0fff
#define sidc_readHandleType(handle,type) type=(((UINT8*)&handle)[2])>>6
#define sidc_readHandleFileIndex(handle,idx) idx=((UINT16*)&handle)[1]&0x3fff

#define sidc_isJpgFile(handle) (((((UINT8*)&handle)[2])>>6)==1)
#define sidc_isScriptFile(handle) (handle>=DPS_MASK_HAND)
extern UINT32 G_ulExifThumbSize;
extern UINT32 G_ulExifThumbAddr;

extern UINT8 RD_Card2DRAM_ReadFile(UINT8 *name,UINT32 startAddr,UINT32 *size);

UINT8 SIDC_ReadWriteData(void);

void SIDC_GetHandles();
void SIDC_GetThumb();
void SIDC_GetPartialObject();
void SIDC_GetObject();
void SIDC_GetObjectInfo();
void SIDC_DeleteObj();
UINT8 SIDC_SendObjInfo(UINT16 size) ;
UINT8 SIDC_SendObject(UINT16 size)  ;

UINT32 SIDC_makeAllHandles();
UINT32 SIDC_makeCurrDirHandles(UINT32 hndIndex);
UINT32 sidc_makeHandleFromOrd(UINT16 fileOrd);
UINT32 sidc_makeHandle(UINT16 fileIndex);
UINT8 SIDC_parsingHandle(UINT32 handle,UINT8 *fileName);
UINT8 SIDC_getFileInfo(UINT32 handle,UINT32 addr,PSIDC_PARA_FILE_INFO pInfo);
void SIDC_getFileInfoStorage(UINT32 handle,PSIDC_PARA_FILE_INFO pInfo);

void SIDC_Init();
#endif /*__SIDCMAIN_H__*/
